Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sourcery refactored master branch #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

sourcery-ai[bot]
Copy link

@sourcery-ai sourcery-ai bot commented Dec 1, 2021

Branch master refactored by Sourcery.

If you're happy with these changes, merge this Pull Request using the Squash and merge strategy.

See our documentation here.

Run Sourcery locally

Reduce the feedback loop during development by using the Sourcery editor plugin:

Review changes via command line

To manually merge these changes, make sure you're on the master branch, then run:

git fetch origin sourcery/master
git merge --ff-only FETCH_HEAD
git reset HEAD^

Help us improve this pull request!

@sourcery-ai sourcery-ai bot requested a review from pkern90 December 1, 2021 10:35
Comment on lines -57 to -65
calibration = {'objpoints': objpoints,
return {'objpoints': objpoints,
'imgpoints': imgpoints,
'cal_images': cal_images,
'mtx': mtx,
'dist': dist,
'rvecs': rvecs,
'tvecs': tvecs}

return calibration
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function calculate_camera_calibration refactored with the following changes:

images = []
for i in range(1, 12):
images.append(imread('../test_images/test%s.jpg' % i))

images = [imread('../test_images/test%s.jpg' % i) for i in range(1, 12)]
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lines 29-32 refactored with the following changes:

abs_s = np.absolute(sobel)

return abs_s
return np.absolute(sobel)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function abs_sobel refactored with the following changes:

Comment on lines -71 to +69
mask = cv2.inRange(hsv, (20, 50, 150), (40, 255, 255))

return mask
return cv2.inRange(hsv, (20, 50, 150), (40, 255, 255))
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function extract_yellow refactored with the following changes:

Comment on lines -83 to +79
mask = cv2.inRange(hsv, (0, 0, 0.), (255, 153, 128))
return mask
return cv2.inRange(hsv, (0, 0, 0.), (255, 153, 128))
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function extract_dark refactored with the following changes:

Comment on lines -95 to +90
mask = cv2.inRange(img, p, 255)
return mask
return cv2.inRange(img, p, 255)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function extract_highlights refactored with the following changes:

Comment on lines -46 to +48
else:
new_left = Line(y=left[0], x=left[1])
new_right = Line(y=right[0], x=right[1])
return are_lanes_plausible(new_left, new_right)
new_left = Line(y=left[0], x=left[1])
new_right = Line(y=right[0], x=right[1])
return are_lanes_plausible(new_left, new_right)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function LaneDetector.__line_plausible refactored with the following changes:

is_parallel = first_coefi_dif < threshold[0] and second_coefi_dif < threshold[1]

return is_parallel
return first_coefi_dif < threshold[0] and second_coefi_dif < threshold[1]
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function Line.is_current_fit_parallel refactored with the following changes:

curverad = ((1 + (2 * fit_cr[0] * y_eval / 2. + fit_cr[1]) ** 2) ** 1.5) / np.absolute(2 * fit_cr[0])

return curverad
return (
(1 + (2 * fit_cr[0] * y_eval / 2.0 + fit_cr[1]) ** 2) ** 1.5
) / np.absolute(2 * fit_cr[0])
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function calc_curvature refactored with the following changes:

@sourcery-ai
Copy link
Author

sourcery-ai bot commented Dec 1, 2021

Sourcery Code Quality Report

✅  Merging this PR will increase code quality in the affected files by 0.13%.

Quality metrics Before After Change
Complexity 3.65 ⭐ 3.54 ⭐ -0.11 👍
Method Length 74.05 🙂 73.41 🙂 -0.64 👍
Working memory 9.88 😞 9.86 🙂 -0.02 👍
Quality 65.28% 🙂 65.41% 🙂 0.13% 👍
Other metrics Before After Change
Lines 764 750 -14
Changed files Quality Before Quality After Quality Change
LaneDetection/CameraCalibration.py 64.48% 🙂 65.06% 🙂 0.58% 👍
LaneDetection/ImageProcessing.py 43.67% 😞 45.88% 😞 2.21% 👍
LaneDetection/ImageUtils.py 71.80% 🙂 71.35% 🙂 -0.45% 👎
LaneDetection/LaneDetector.py 54.83% 🙂 55.22% 🙂 0.39% 👍
LaneDetection/Line.py 75.88% ⭐ 75.94% ⭐ 0.06% 👍

Here are some functions in these files that still need a tune-up:

File Function Complexity Length Working Memory Quality Recommendation
LaneDetection/LaneDetector.py LaneDetector.process_frame 17 🙂 296 ⛔ 13 😞 32.48% 😞 Try splitting into smaller methods. Extract out complex expressions
LaneDetection/CameraCalibration.py calculate_camera_calibration 6 ⭐ 204 😞 15 😞 44.30% 😞 Try splitting into smaller methods. Extract out complex expressions
LaneDetection/ImageUtils.py generate_lane_mask 0 ⭐ 184 😞 15 😞 51.81% 🙂 Try splitting into smaller methods. Extract out complex expressions
LaneDetection/ImageUtils.py histogram_lane_detection 3 ⭐ 158 😞 13 😞 53.90% 🙂 Try splitting into smaller methods. Extract out complex expressions
LaneDetection/ImageUtils.py draw_poly_arr 4 ⭐ 82 🙂 13 😞 62.38% 🙂 Extract out complex expressions

Legend and Explanation

The emojis denote the absolute quality of the code:

  • ⭐ excellent
  • 🙂 good
  • 😞 poor
  • ⛔ very poor

The 👍 and 👎 indicate whether the quality has improved or gotten worse with this pull request.


Please see our documentation here for details on how these metrics are calculated.

We are actively working on this report - lots more documentation and extra metrics to come!

Help us improve this quality report!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

0 participants